package myfloat.floatlistview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.melnykov.fab.FloatingActionButton;

import java.util.ArrayList;
import java.util.List;

public class Floating extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_floating);
        initview();
    }

    private void initview() {
        ListView lv = (ListView) findViewById(R.id.list_float);
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            data.add("ss" + i);
        }
        ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, data);
        lv.setAdapter(adapter);
        fab.attachToListView(lv);
        fab.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Toast.makeText(this, "点击了", Toast.LENGTH_LONG).show();
    }
}
